'use strict'

const BaseController  = require('./base');

class ArticleController extends BaseController {
    // 获取文章列表
    async articleList(){
        const data = await this.ctx.service.article.articleList(this.ctx.request.body)
        this.success(data)
    }

    //根据用户id获取文章
    async articleByUser(){
        
    }

    // 创建文章(客户端)
    async createArticle(){
        await this.ctx.service.article.createArticle(this.ctx.request.body)
        this.success(null,"创建文章成功！")
    }

    // 删除文章
    async deleteArticle(){
        await this.ctx.service.article.deleteArticle(this.ctx.request.body.ids)
        this.success()
    }

    // 审核文章
    async auditArticle(){
        await this.ctx.service.article.auditArticle(this.ctx.request.body)
        this.success()
    }

    // 编辑草稿
    async editArticle(){
        const tips =  await this.ctx.service.article.editArticle(this.ctx.request.body)
        this.success(null,tips)
    }

    // 根据id获取文章
    async getArticleById(){
        const tips =  await this.ctx.service.article.findArticleById(this.ctx.request.body.id)
        this.success(tips)
    }
    // 获取推荐文章列表
    async getReCommentArticle(){
        const tips =  await this.ctx.service.article.getReCommentArticle(this.ctx.request.body)
        this.success(tips)
    }
    
}

module.exports = ArticleController;